package edu.lsnu.equipment_management_system.service.impl;

import edu.lsnu.equipment_management_system.mapper.insert.AdminAddUserMapper;
import edu.lsnu.equipment_management_system.mapper.insert.EquipmentInformationTableMapper;
import edu.lsnu.equipment_management_system.service.CheckUserAndEquipmentDoesNotExistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author mzy
 * @Description 判断职工号和设备编号是否存在，存在为false，不存在为true。
 * @date 2018/11/18
 */
@Service
public class CheckUserAndEquipmentDoesNotExistServiceImpl implements CheckUserAndEquipmentDoesNotExistService {
    @Autowired
    AdminAddUserMapper adminAddUserMapper;
    @Autowired
    EquipmentInformationTableMapper equipmentInformationTableMapper;

    /**
     * @Description 不存在为true，存在为false。
     * @author mzy
     * @time 2018-11-23
     * @see
     * @return   boolean
     * @params  [equipmentNo]
     */
    @Override
    public boolean checkEquipmentNoDoesNotExist(String equipmentNo) {
        int count = equipmentInformationTableMapper.existEquipment(equipmentNo);

        if (count == 0) {
            return true;
        }

        return false;
    }

    /**
     * @Description 不存在为true，存在为false。
     * @author mzy
     * @time 2018-11-23
     * @see
     * @return   boolean
     * @params  [userNo]
     */
    @Override
    public boolean checkUserNoDoesNotExist(String userNo) {
        int count = adminAddUserMapper.existUser(userNo);

        if (count == 0) {
            return true;
        }

        return false;
    }


}
